<template>
  <div class="successful-case">
    <TitleBar title="成功案例"></TitleBar>
    <header class="home-page-banner"></header>
    <div class="successfun-case-list">
      <SuccessfulCaseItem v-for="item in caseList" :key="item.catid" :catName="item.catname" :year="item.year" :date="item.addtime" @click.native="goSuccessDetail(item.bangdan_catid)"></SuccessfulCaseItem>
    </div>
    <MyFooter :introduceShow="true"></MyFooter>
  </div>
</template>

<script>
import TitleBar from '../../components/TitleBar'
import SuccessfulCaseItem from '../../components/SuccessfulCaseItem'
import MyFooter from '../../components/MyFooter'
import * as events from '../../store/events'
export default {
  components: {
    TitleBar,
    SuccessfulCaseItem,
    MyFooter
  },
  data() {
    return {
      caseList: []
    }
  },
  mounted() {
    this.$showLoading()
    this.$api.postCaseList().then(data => {
      this.$hideLoading()
      if (data.data.status == 1) {
        this.caseList = data.data.caseList
        // 解决ios回退白屏的问题，勿删
        window.scrollTo(0, 1)
        window.scrollTo(0, 0)
        // 客服数据
        let service = {
          email: data.data.setting.service_email,
          tel: data.data.setting.service_tel
        }
        // 客服数据存到store中
        this.$store.commit(events.SET_SERVICE_INFO, service)
      }
    })
  },
  methods: {
    goSuccessDetail(catid) {
      if (this.$route.query.catid) {
        this.$router.push('/newEndPage/?successCatid=' + catid + '&pageform=successfulCase' + '&catid=' + this.$route.query.catid)
      } else {
        this.$router.push('/newEndPage/?successCatid=' + catid + '&pageform=successfulCase')
      }
    }
  }
}
</script>

<style scoped lang="scss">
.successfun-case-list {
  margin-top: 0.4rem;
}
</style>
